<template>
  <el-table :data="list" border style="width: 100%">
    <el-table-column prop="name" label="门店名称" />
    <el-table-column prop="shopId" label="所属门店">
      <template slot-scope="{ row }">
        <span>{{ getShopName(row.shopId) }}</span>
      </template>
    </el-table-column>
    <el-table-column prop="state" label="状态">
      <template slot-scope="{ row }">
        <span>{{ row.state === 1 ? '业绩冲刺中' : '休息中' }}</span>
      </template>
    </el-table-column>
    <el-table-column label="操作" width="200px" align="center">>
      <template slot-scope="{ row }">
        <el-button type="primary" plain size="mini" @click="edit(row)">编辑</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
import { broadcast } from "@/utils/util";
export default {
  name: "TeamTable",
  props: {
    list: {
      type: Array,
      default: () => [],
    },
    shopList: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    getShopName(shopId) {
      return (
        this.shopList.find((item) => Number(item.value) === Number(shopId))
          ?.label || "-"
      );
    },
    handleInput(row) {
      this.$parent.inputDialog = {
        visible: true,
        content: row,
      };
    },
    edit(row) {
      const { id, name, shopId, state } = row;
      let params = { id, name, shopId, state, type: "edit" };
      // this.$router.push({
      //   name: 'TeamCreate',
      //   params: params
      // })
      broadcast("look.user.team", { type: "edit", data: params });
      console.log("操作");
    },
  },
};
</script>
